package com.ssy.lingxi.report.api.enums;

import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;

public enum OperateDataSourceEnum {

    MEMBER(1, "会员"),//废弃
    TRADE_COMMODITY_INQUIRY(2, "商品询价"),
    TRADE_INQUIRY_QUOTATION(3, "询价报价"),
    TRADE_CONFIRM_INQUIRY_QUOTATION(4, "确认询价报价"),
    TRADE_DEMAND_PUBLISH(5, "需求发布"),
    TRADE_DEMAND_QUOTATION(6, "交易中心需求报价"),
    TRADE_CONFIRM_DEMAND_QUOTATION(7, "确认需求报价"),
    TRADE_SALE_ORDER(8, "销售订单"),
    TRADE_PURCHASE_ORDER(9, "采购订单"),
    COMMODITY(10, "商品中心"),
    ACCOUNT(11, "资金账户"),
    CREDIT(12, "授信"),
    LOGISTICS(13, "物流"),
    ENHANCE_PROCESS(14, "确认生产通知单"),
    ENHANCE_SUPPLIER(15, "指派生产通知单"),
    SETTLE_ACCOUNT_PLATFORM(16, "平台结算"),
    SETTLE_ACCOUNT_PLATFORM_SCORE(17, "平台积分结算"),
    SETTLE_ACCOUNT_PAYABLE(18, "应付账款结算"),
    SETTLE_ACCOUNT_RECEIVABLE(19, "应收账款结算"),
    AFTER_SALE_REPLACE_APPLY(20, "售后换货申请"),
    AFTER_SALE_REPLACE_HANDLE(21, "售后换货处理"),
    AFTER_SALE_RETURN_APPLY(22, "售后退货申请"),
    AFTER_SALE_RETURN_HANDLE(23, "售后退货处理"),
    AFTER_SALE_REPAIR_APPLY(24, "售后维修申请"),
    AFTER_SALE_REPAIR_HANDLE(25, "售后维修处理"),
    SHOP(26, "店铺"),
    MEMBER_IMPORT(27, "会员入库"),
    MEMBER_CHANGE(28, "会员变更"),
    MEMBER_KPI(29, "会员考评"),
    MEMBER_RECTIFY(30, "会员整改"),
    MEMBER_RECTIFY_NOTICE(31, "会员整改通知"),
    CONTRACT_MANAGE(32, "合同管理"),
    CONTRACT_COORDINATION(33, "合同协同"),
    CONTRACT_APPLY_AMOUNT_ORDER(34, "合同请款"),
    PURCHASE_INQUIRY(35, "采购询价"),
    PURCHASE_QUOTED_PRICE(36, "报价"),
    PURCHASE_CONFIRM_QUOTED_PRICE(37, "确认报价"),
    PURCHASE_BIDDING(38, "采购竞价"),
    PURCHASE_ONLINE_BIDDING(39, "在线竞价"),
    PURCHASE_INVITE_TENDER(40, "招标"),
    PURCHASE_TENDER(41, "投标"),
    PURCHASE_NEED_PLAN(42, "需求计划"),
    PURCHASE_PLAN(43, "采购计划"),
    PLATFORM_MEMBER_VERIFY(44, "平台会员审核"),
    PLATFORM_PURCHASE(45, "平台采购统计"),
    PLATFORM_AFTER_SALE(46, "平台售后统计"),
    SETTLE_ACCOUNT_PLATFORM_COUPON(47, "平台优惠券结算"),
    ;
    /**
     * 编码
     */
    private final Integer code;
    /**
     * 名称
     */
    private final String name;

    OperateDataSourceEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public static OperateDataSourceEnum getEnum(Integer code) {
        return Arrays.stream(OperateDataSourceEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(null);
    }

    public static String getItemName(Integer code) {
        OperateDataSourceEnum sourceEnum = Arrays.stream(OperateDataSourceEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(null);
        return (null != sourceEnum ? sourceEnum.getName() : "");
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return LanguageHolder.getName(this.getClass(), this.code);
    }

}
